using UnityEngine;

public class ETCSingleton<T> : MonoBehaviour where T : ETCSingleton<T>
{
	private static T m_Instance;

	public static T instance
	{
		get
		{
			if ((Object)m_Instance == (Object)null)
			{
				m_Instance = (UnityEngine.Object.FindObjectOfType(typeof(T)) as T);
				if ((Object)m_Instance == (Object)null)
				{
					m_Instance = new GameObject("VirtualControlInput", typeof(T)).GetComponent<T>();
					m_Instance.Init();
				}
			}
			return m_Instance;
		}
	}

	private void Awake()
	{
		if ((Object)m_Instance == (Object)null)
		{
			m_Instance = (this as T);
		}
	}

	public virtual void Init()
	{
	}

	private void OnApplicationQuit()
	{
		m_Instance = (T)null;
	}
}
